package a.f.l;

import a.c.ab;
import a.c.bb;
import a.c.d;
import a.c.e;
import a.c.m;
import a.c.n;
import a.c.x;
import a.f.o;
import a.f.r;
import a.f.*;
import a.i.db;
import a.i.l;
import a.i.q;

import java.awt.geom.Rectangle2D;
import java.util.*;

public class k
  extends r
{
  private static final boolean g = false;
  private int h = 1000;
  public static int i;
  
  public k(rc paramrc)
  {
    a(paramrc);
  }
  
  public boolean canLayout(o paramo)
  {
    return a().canLayout(paramo);
  }
  
  public void a(int paramInt)
  {
    this.h = paramInt;
  }
  
  public int b()
  {
    return this.h;
  }
  
  public void doLayout(o paramo)
  {
    int i5 = g.Cc;
    int i4 = g.Bc;
    g localg = c();
    if (localg == null) {
      throw new IllegalStateException("No OrthogonalEdgeRouter in coreLayouter");
    }
    if ((i5 != 0) || (!a(paramo, localg)))
    {
      a().doLayout(paramo);
      return;
    }
    x localx1 = paramo.B();
    int j = 2147483647;
    int k = Math.min(b() / 4, 200);
    int m = k;
    int n = k;
    if (n <= Math.max(k, 2000)) {}
    label189:
    do
    {
      int i1 = a(paramo, localx1, n);
      int i2 = paramo.j() / i1;
      localObject1 = a(paramo, localx1);
      if (i4 != 0) {
        break label213;
      }
      if (localObject1 != null)
      {
        if (i5 != 0) {
          break label189;
        }
        if (((Set)localObject1).size() < j)
        {
          if (i5 != 0) {
            break label189;
          }
          if (i2 < j)
          {
            j = ((Set)localObject1).size();
            m = n;
          }
        }
      }
      n = (int)(n * 2.0D);
      if (i4 == 0) {
        break;
      }
      n = a(paramo, localx1, m);
    } while (i5 != 0);
    label213:
    Set localSet = a(paramo, localx1);
    x localx2 = paramo.B();
    Object localObject1 = paramo.C();
    ab localab1 = new ab();
    bb localbb1 = new bb();
    Object localObject2 = paramo.w();
    do
    {
      if (!((m)localObject2).e()) {
        break;
      }
      localObject3 = ((m)localObject2).a();
      if (i5 == 0)
      {
        if (localx1.getInt(((d)localObject3).e()) != localx1.getInt(((d)localObject3).f()))
        {
          ((n)localObject1).a(localObject3, true);
          localab1.add(localObject3);
          localx2.a(((d)localObject3).e(), true);
          localx2.a(((d)localObject3).f(), true);
        }
        ((m)localObject2).f();
      }
    } while (i4 == 0);
    localObject2 = new a.i.y(paramo);
    Object localObject3 = paramo.w();
    if (((m)localObject3).e()) {
      if (i5 == 0) {
        if (((n)localObject1).getBool(((m)localObject3).a())) {}
      }
    }
    while (i5 != 0)
    {
      ((a.i.y)localObject2).a(((m)localObject3).a());
      ((m)localObject3).f();
      if (i4 == 0) {
        break;
      }
    }
    localObject3 = new a.i.y(paramo);
    Object localObject4 = paramo.v();
    do
    {
      while (i4 == 0)
      {
        if (!((a.c.w)localObject4).e()) {
          break;
        }
        if (i5 == 0)
        {
          if (!localx2.getBool(((a.c.w)localObject4).d())) {
            ((a.i.y)localObject3).a(((a.c.w)localObject4).d());
          }
          ((a.c.w)localObject4).f();
        }
      }
    } while (i5 != 0);
    localObject4 = null;
    Iterator localIterator;
    if (localSet != null)
    {
      localObject4 = new ArrayList(localSet.size());
      localIterator = localSet.iterator();
      do
      {
        if (!localIterator.hasNext()) {
          break;
        }
        localObject5 = (Rectangle2D)localIterator.next();
        localObject6 = paramo.i();
        if (i5 != 0) {
          break label645;
        }
        ((List)localObject4).add(localObject6);
        paramo.b((e)localObject6, ((Rectangle2D)localObject5).getWidth(), ((Rectangle2D)localObject5).getHeight());
        paramo.c((e)localObject6, ((Rectangle2D)localObject5).getX(), ((Rectangle2D)localObject5).getY());
        if (i4 != 0) {
          break label643;
        }
      } while (i4 == 0);
    }
    if (i5 == 0) {
      a().doLayout(paramo);
    }
    label643:
    label645:
    if ((i5 != 0) || (localObject4 != null))
    {
      localIterator = ((List)localObject4).iterator();
      do
      {
        if (!localIterator.hasNext()) {
          break;
        }
        paramo.a((e)localIterator.next());
        if (i5 != 0) {
          break label720;
        }
        if (i4 != 0) {
          break label716;
        }
      } while (i4 == 0);
    }
    ((a.i.y)localObject3).g();
    if (i5 == 0) {
      ((a.i.y)localObject2).g();
    }
    label716:
    label720:
    byte b = localg.G();
    Object localObject5 = localg.c();
    Object localObject6 = paramo.c(localObject5);
    localg.b((byte)2);
    paramo.a(localObject5, q.c((a.c.k)localObject1));
    a.i.z localz = new a.i.z(paramo, localx1);
    localz.b();
    bb localbb2 = new bb();
    ab localab2 = new ab();
    int i3 = 0;
    do
    {
      if (i3 >= n) {
        break;
      }
      Integer localInteger = new Integer(i3);
      localz.b(localInteger);
      a(localab2, localbb2, localab1, paramo);
      a().doLayout(paramo);
      a(localab2, localbb2, paramo);
      localz.a(localInteger);
      i3++;
      if ((i5 == 0) && (i4 != 0)) {
        break label879;
      }
    } while (i4 == 0);
    if (i5 == 0) {
      localz.g();
    }
    label879:
    if (localObject6 != null)
    {
      paramo.a(localObject5, (a.c.k)localObject6);
      if (i5 != 0) {
        return;
      }
      if (i4 == 0) {}
    }
    else
    {
      paramo.j(localObject5);
    }
    localg.b(b);
    paramo.a((n)localObject1);
    paramo.a(localx2);
    paramo.a(localx1);
  }
  
  g c()
  {
    int k = g.Cc;
    int j = g.Bc;
    do
    {
      rc localrc = a();
      while (j == 0)
      {
        if (!(localrc instanceof vc)) {
          break;
        }
        if (k == 0)
        {
          if ((localrc instanceof g)) {
            return (g)localrc;
          }
          localrc = ((vc)localrc).a();
        }
      }
    } while (k != 0);
    return null;
  }
  
  void a(ab paramab, bb parambb, o paramo)
  {
    int k = g.Cc;
    int j = g.Bc;
    label14:
    do
    {
      if (paramab.isEmpty()) {
        break;
      }
      break;
      paramo.f(paramab.o());
      if ((k == 0) && (j != 0)) {
        break label65;
      }
    } while (j == 0);
    label60:
    label65:
    while (k != 0)
    {
      break label60;
      if (k != 0) {
        break label14;
      }
      if (!parambb.isEmpty())
      {
        paramo.d(parambb.o());
        if (j == 0) {
          break;
        }
      }
    }
  }
  
  void a(ab paramab1, bb parambb, ab paramab2, o paramo)
  {
    int k = g.Cc;
    int j = g.Bc;
    Rectangle2D.Double localDouble = new Rectangle2D.Double();
    paramab1.clear();
    parambb.clear();
    Rectangle2D localRectangle2D = wc.a(paramo, paramo.v());
    localRectangle2D.setFrame(localRectangle2D.getX() - 10.0D, localRectangle2D.getY() - 10.0D, localRectangle2D.getWidth() + 20.0D, localRectangle2D.getHeight() + 20.0D);
    m localm = paramab2.l();
    label269:
    label273:
    label337:
    do
    {
      if (!localm.e()) {
        break;
      }
      d locald;
      do
      {
        locald = localm.a();
        a.c.z localz = paramo.o(locald);
        Object localObject1 = localz.h();
        do
        {
          if (!((a.c.y)localObject1).e()) {
            break label269;
          }
          localObject2 = (a.d.w)((a.c.y)localObject1).j();
          if (j != 0) {
            break;
          }
          if (localRectangle2D.contains(((a.d.w)localObject2).a, ((a.d.w)localObject2).b))
          {
            paramab1.add(locald);
            if (k == 0) {
              if (locald.e().g() == null)
              {
                paramo.e(locald.e());
                parambb.add(locald.e());
              }
            }
            if (locald.f().g() == null)
            {
              paramo.e(locald.f());
              parambb.add(locald.f());
            }
            if (k != 0) {
              break label273;
            }
            paramo.g(locald);
            if (j == 0) {
              break label269;
            }
          }
          ((a.c.y)localObject1).f();
        } while (j == 0);
        localObject1 = paramo.k(locald.e());
        if (k != 0) {
          break label337;
        }
        localDouble.setFrame(((zc)localObject1).a(), ((zc)localObject1).b(), ((zc)localObject1).c(), ((zc)localObject1).d());
      } while (k != 0);
      if (locald.e().g() == null) {
        if (k == 0)
        {
          if (localRectangle2D.intersects(localDouble)) {
            paramo.e(locald.e());
          }
        }
        else {
          parambb.add(locald.e());
        }
      }
      Object localObject2 = paramo.k(locald.f());
      localDouble.setFrame(((zc)localObject2).a(), ((zc)localObject2).b(), ((zc)localObject2).c(), ((zc)localObject2).d());
      if (k == 0)
      {
        if (locald.f().g() == null)
        {
          if (k != 0) {
            continue;
          }
          if (localRectangle2D.intersects(localDouble))
          {
            paramo.e(locald.f());
            parambb.add(locald.f());
          }
        }
        localm.f();
      }
    } while (j == 0);
  }
  
  int a(o paramo, x paramx, int paramInt)
  {
    e[] arrayOfe = paramo.t();
    c_ localc_1 = new c_(paramo, true);
    c_ localc_2 = new c_(paramo, false);
    return a(paramx, paramInt, arrayOfe, 0, arrayOfe.length, localc_1, localc_2, true, 0);
  }
  
  int a(x paramx, int paramInt1, e[] paramArrayOfe, int paramInt2, int paramInt3, Comparator paramComparator1, Comparator paramComparator2, boolean paramBoolean, int paramInt4)
  {
    int n = g.Cc;
    int m = g.Bc;
    int j = paramInt3 - paramInt2 - 1;
    if (n == 0) {
      if (j < paramInt1)
      {
        int k = paramInt2;
        if (k < paramInt3)
        {
          paramx.a(paramArrayOfe[k], paramInt4);
          k++;
        }
        for (;;)
        {
          if (n == 0) {
            if (m == 0)
            {
              if (m == 0) {
                break;
              }
              if (n != 0) {
                continue;
              }
              paramInt4++;
            }
          }
        }
        if (n != 0) {
          break label193;
        }
        if (m == 0) {
          break label191;
        }
      }
    }
    Comparator localComparator = paramBoolean ? paramComparator1 : paramComparator2;
    l.a(paramArrayOfe, paramInt2, paramInt3, localComparator);
    if (n == 0) {}
    paramInt4 = a(paramx, paramInt1, paramArrayOfe, paramInt2, paramInt2 + j / 2, paramComparator1, paramComparator2, !paramBoolean, paramInt4);
    if (n == 0) {}
    paramInt4 = a(paramx, paramInt1, paramArrayOfe, paramInt2 + j / 2, paramInt3, paramComparator1, paramComparator2, !paramBoolean, paramInt4);
    label191:
    label193:
    return paramInt4;
  }
  
  double c(o paramo)
  {
    int k = g.Cc;
    int j = g.Bc;
    double d = 0.0D;
    if (k == 0) {
      if (paramo.n()) {
        return 0.0D;
      }
    }
    a.c.w localw = paramo.v();
    if (localw.e())
    {
      d += paramo.s(localw.d());
      if (k != 0) {}
    }
    while (k != 0)
    {
      if (j != 0) {
        break label108;
      }
      d += paramo.t(localw.d());
      localw.f();
      if (j == 0) {
        break;
      }
    }
    label108:
    return d / (2.0D * paramo.j());
  }
  
  Set a(o paramo, a.c.k paramk)
  {
    int k = g.Cc;
    int j = g.Bc;
    double d1 = c(paramo);
    x localx = db.a(new boolean[paramo.j()]);
    Object localObject = paramo.w();
    do
    {
      if (!((m)localObject).e()) {
        break;
      }
      d locald = ((m)localObject).a();
      if (k == 0)
      {
        if (paramk.getInt(locald.e()) != paramk.getInt(locald.f()))
        {
          localx.a(locald.e(), true);
          localx.a(locald.f(), true);
        }
        ((m)localObject).f();
      }
    } while (j == 0);
    localObject = a(paramo, localx, d1);
    if (localObject == null) {
      return null;
    }
    double d2 = d1;
    double d3 = ((Set)localObject).size();
    double d4 = d1 / 2.0D;
    do
    {
      do
      {
        if (d4 <= 10.0D) {
          break;
        }
        localObject = a(paramo, localx, d4);
        if (j != 0) {
          break label335;
        }
        if (localObject != null)
        {
          if (k != 0) {
            continue;
          }
          if (((Set)localObject).size() < d3)
          {
            d3 = ((Set)localObject).size();
            d2 = d4;
          }
        }
        d4 /= 2.0D;
      } while (j == 0);
    } while (k != 0);
    d4 = d1 * 2.0D;
    if (d4 < 1000.0D) {}
    label318:
    while (k != 0)
    {
      localObject = a(paramo, localx, d4);
      if (j != 0) {
        break label335;
      }
      if (localObject != null)
      {
        if (k != 0) {
          break label318;
        }
        if (((Set)localObject).size() < d3)
        {
          d3 = ((Set)localObject).size();
          d2 = d4;
        }
      }
      d4 *= 2.0D;
      if (j == 0) {
        break;
      }
    }
    label335:
    return a(paramo, localx, d2);
  }
  
  Set a(o paramo, a.c.k paramk, double paramDouble)
  {
    int m = g.Cc;
    int k = g.Bc;
    HashSet localHashSet1 = new HashSet();
    HashSet localHashSet2 = new HashSet();
    Rectangle2D.Double localDouble = new Rectangle2D.Double();
    Object localObject1 = paramo.v();
    double d1;
    double d2;
    double d3;
    double d4;
    double d5;
    double d6;
    label209:
    do
    {
      do
      {
        if (!((a.c.w)localObject1).e()) {
          break;
        }
        localObject2 = ((a.c.w)localObject1).d();
        if (k != 0) {
          break label260;
        }
        if (paramk.getBool(localObject2))
        {
          d1 = paramo.p((e)localObject2);
          d2 = paramo.q((e)localObject2);
          d3 = paramo.s((e)localObject2);
          d4 = paramo.t((e)localObject2);
          d5 = (int)(d1 / paramDouble) * paramDouble;
          do
          {
            if (d5 >= d1 + d3) {
              break;
            }
            if (k != 0) {
              break label328;
            }
            d6 = (int)(d2 / paramDouble) * paramDouble;
            do
            {
              do
              {
                if (d6 >= d2 + d4) {
                  break label209;
                }
                localDouble.setFrame(d5, d6, paramDouble, paramDouble);
                if (k != 0) {
                  break;
                }
                if (!localHashSet2.contains(localDouble)) {
                  localHashSet2.add(localDouble.getBounds2D());
                }
                d6 += paramDouble;
              } while (k == 0);
              d5 += paramDouble;
            } while (m != 0);
          } while (k == 0);
        }
        ((a.c.w)localObject1).f();
        if (m != 0) {
          break label497;
        }
      } while (k == 0);
    } while (m != 0);
    localObject1 = paramo.v();
    label260:
    label328:
    label472:
    label488:
    label497:
    while (k == 0)
    {
      if (!((a.c.w)localObject1).e()) {
        break;
      }
      localObject2 = ((a.c.w)localObject1).d();
      if (k != 0) {
        break label512;
      }
      if (!paramk.getBool(localObject2))
      {
        d1 = paramo.p((e)localObject2);
        d2 = paramo.q((e)localObject2);
        d3 = paramo.s((e)localObject2);
        d4 = paramo.t((e)localObject2);
        d5 = (int)(d1 / paramDouble) * paramDouble;
        do
        {
          do
          {
            if (d5 >= d1 + d3) {
              break;
            }
          } while (k != 0);
          d6 = (int)(d2 / paramDouble) * paramDouble;
          do
          {
            do
            {
              if (d6 >= d2 + d4) {
                break label472;
              }
              localDouble.setFrame(d5, d6, paramDouble, paramDouble);
              if (k != 0) {
                break;
              }
              if (localHashSet2.contains(localDouble))
              {
                localDouble.setFrame(d1, d2, d3, d4);
                localHashSet1.add(localDouble.getBounds2D());
                if (m != 0) {
                  break label497;
                }
                if (k == 0) {
                  break label488;
                }
              }
              if (m == 0)
              {
                if (!localHashSet1.contains(localDouble)) {
                  localHashSet1.add(localDouble.getBounds2D());
                }
                d6 += paramDouble;
              }
            } while (k == 0);
            d5 += paramDouble;
          } while (m != 0);
        } while (k == 0);
      }
      ((a.c.w)localObject1).f();
    }
    if (m == 0) {
      if (localHashSet1.isEmpty()) {
        label512:
        return null;
      }
    }
    localObject1 = (Rectangle2D.Double[])localHashSet1.toArray(new Rectangle2D.Double[localHashSet1.size()]);
    l.a((Object[])localObject1, new Comparator()
    {
      public int compare(Object paramAnonymousObject1, Object paramAnonymousObject2)
      {
        Rectangle2D.Double localDouble1 = (Rectangle2D.Double)paramAnonymousObject1;
        Rectangle2D.Double localDouble2 = (Rectangle2D.Double)paramAnonymousObject2;
        int i = l.a(localDouble1.y, localDouble2.y);
        if (g.Cc == 0)
        {
          if (i != 0) {
            return i;
          }
          i = l.a(localDouble1.x, localDouble2.x);
        }
        return i;
      }
    });
    Object localObject2 = localObject1[0];
    int j = 1;
    Object localObject3;
    label687:
    label689:
    do
    {
      if (j >= localObject1.length) {
        break;
      }
      localObject3 = localObject1[j];
      if (k != 0) {
        break label744;
      }
      if (((Rectangle2D.Double)localObject2).getMaxX() == localObject3.getMinX())
      {
        if (m != 0) {
          break label687;
        }
        if (((Rectangle2D.Double)localObject2).getMinY() == localObject3.getMinY())
        {
          localHashSet1.remove(localObject2);
          localHashSet1.remove(localObject3);
          ((Rectangle2D.Double)localObject2).setFrame(((Rectangle2D.Double)localObject2).x, ((Rectangle2D.Double)localObject2).y, ((Rectangle2D.Double)localObject2).width + localObject3.width, ((Rectangle2D.Double)localObject2).height);
          localHashSet1.add(localObject2);
          if (m != 0) {
            continue;
          }
          if (k == 0) {
            break label689;
          }
        }
      }
      localObject2 = localObject3;
      j++;
    } while (k == 0);
    localObject1 = (Rectangle2D.Double[])localHashSet1.toArray(new Rectangle2D.Double[localHashSet1.size()]);
    l.a((Object[])localObject1, new Comparator()
    {
      public int compare(Object paramAnonymousObject1, Object paramAnonymousObject2)
      {
        Rectangle2D.Double localDouble1 = (Rectangle2D.Double)paramAnonymousObject1;
        Rectangle2D.Double localDouble2 = (Rectangle2D.Double)paramAnonymousObject2;
        int i = l.a(localDouble1.x, localDouble2.x);
        if (g.Cc == 0)
        {
          if (i != 0) {
            return i;
          }
          i = l.a(localDouble1.y, localDouble2.y);
        }
        return i;
      }
    });
    localObject2 = localObject1[0];
    if (m == 0) {
      label744:
      j = 1;
    }
    label891:
    label893:
    do
    {
      if (j >= localObject1.length) {
        break;
      }
      localObject3 = localObject1[j];
      if (m == 0) {
        if (((Rectangle2D.Double)localObject2).getMaxY() == localObject3.getMinY())
        {
          if (m != 0) {
            break label891;
          }
          if (((Rectangle2D.Double)localObject2).getMinX() == localObject3.getMinX())
          {
            if (m != 0) {
              break label891;
            }
            if (((Rectangle2D.Double)localObject2).getMaxX() == localObject3.getMaxX())
            {
              localHashSet1.remove(localObject2);
              localHashSet1.remove(localObject3);
              ((Rectangle2D.Double)localObject2).setFrame(((Rectangle2D.Double)localObject2).x, ((Rectangle2D.Double)localObject2).y, ((Rectangle2D.Double)localObject2).width, ((Rectangle2D.Double)localObject2).height + localObject3.height);
              localHashSet1.add(localObject2);
              if (m != 0) {
                continue;
              }
              if (k == 0) {
                break label893;
              }
            }
          }
        }
      }
      localObject2 = localObject3;
      j++;
    } while (k == 0);
    return localHashSet1;
  }
  
  boolean a(o paramo, g paramg)
  {
    int j = g.Cc;
    if (j == 0) {
      if (paramg.G() != 0) {
        return false;
      }
    }
    if (j == 0) {
      if (paramo.j() + paramo.l() < b()) {
        return false;
      }
    }
    return true;
  }
  
  static class c_
    implements Comparator
  {
    o a;
    boolean b;
    
    c_(o paramo, boolean paramBoolean)
    {
      this.a = paramo;
      this.b = paramBoolean;
    }
    
    public int compare(Object paramObject1, Object paramObject2)
    {
      int j = g.Cc;
      if (j == 0) {}
      int i = this.b ? l.a(this.a.p((e)paramObject1), this.a.p((e)paramObject2)) : l.a(this.a.q((e)paramObject1), this.a.q((e)paramObject2));
      if (j == 0)
      {
        if (i != 0) {
          return i;
        }
        if (j != 0) {
          break label123;
        }
      }
      label123:
      i = !this.b ? l.a(this.a.p((e)paramObject1), this.a.p((e)paramObject2)) : l.a(this.a.q((e)paramObject1), this.a.q((e)paramObject2));
      return i;
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.l.k

 * JD-Core Version:    0.7.0.1

 */